package ending;
class Clerk{ //店员
    private int productNum = 0;  //产品数量

    //增加产品数量
    public void add(){

    }
    //减少产品数量
    public void produce(){

    }
}
class Producer extends Thread{  //生产者

    private Clerk clerk;

    public Producer(Clerk clerk){
        this.clerk = clerk;
    }
    @Override
    public void run() {
        while(true){
            System.out.println("生产者开始生产商品");
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            clerk.add();
        }
    }
}
class Consumer extends Thread{  //消费者

    private Clerk clerk;

    public Consumer(Clerk clerk){
        this.clerk = clerk;
    }
    @Override
    public void run() {
        while(true){
            System.out.println("消费者购买产品");
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            clerk.produce();
        }
    }

}
public class ProducerConsumerTest {
}
